
package me.zhengjie.domain;

import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import javax.persistence.*;
import javax.persistence.Entity;
import javax.persistence.Table;

import me.zhengjie.service.dto.AppEventDto;
import org.hibernate.annotations.*;
import org.springframework.beans.BeanUtils;

import java.sql.Timestamp;
import java.io.Serializable;

/**
* @website https://el-admin.vip
* @description /
* @author IQW
* @date 2022-07-03
**/
@Entity
@Data
@Table(name="app_event")
public class AppEvent implements Serializable {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "event_id")
    @ApiModelProperty(value = "事件ID")
    private Integer eventId;

    @Column(name = "area_id")
    @ApiModelProperty(value = "责任区ID")
    private Integer areaId;

    @Column(name = "work_id")
    @ApiModelProperty(value = "任务ID")
    private Integer workId;

    @Column(name = "user_id")
    @ApiModelProperty(value = "上报用户ID")
    private Integer userId;

    @Column(name = "fid")
    @ApiModelProperty(value = "父类ID")
    private Integer fid;

    @Column(name = "to_user_id")
    @ApiModelProperty(value = "处理人用户ID")
    private Integer toUserId;

    @Column(name = "to_user_id2")
    @ApiModelProperty(value = "处理人用户ID2")
    private Integer toUserId2;

    @Column(name = "to_user_id3")
    @ApiModelProperty(value = "处理人用户ID3")
    private Integer toUserId3;

    @Column(name = "title")
    @ApiModelProperty(value = "标题")
    private String title;

    @Column(name = "type")
    @ApiModelProperty(value = "类型（1普通事件，2日常巡护，3紧急事件）")
    private Integer type;

    @Column(name = "cate_id")
    @ApiModelProperty(value = "事件类型ID")
    private Integer cateId;

    @Column(name = "cate")
    @ApiModelProperty(value = "事件类型名称")
    private String cate;

    @Column(name = "icon")
    @ApiModelProperty(value = "图标")
    private String icon;

    @Column(name = "note")
    @ApiModelProperty(value = "描述")
    private String note;

    @Column(name = "imgs")
    @ApiModelProperty(value = "图片")
    private String imgs;

    @Column(name = "voice")
    @ApiModelProperty(value = "录音")
    private String voice;

    @Column(name = "vtime")
    @ApiModelProperty(value = "录音时长")
    private Integer vtime;

    @Column(name = "address")
    @ApiModelProperty(value = "目标地址")
    private String address;

    @Column(name = "lon")
    @ApiModelProperty(value = "目的地经度")
    private Double lon;

    @Column(name = "lat")
    @ApiModelProperty(value = "目的地纬度")
    private Double lat;

    @Column(name = "add_time",nullable = false)
    @CreationTimestamp
    @ApiModelProperty(value = "上报时间")
    private Timestamp addTime;

    @Column(name = "end_time")
    @ApiModelProperty(value = "处理时间")
    private Timestamp endTime;

    @Column(name = "act_way")
    @ApiModelProperty(value = "处理方式（1无需处理，2立即处理，3分配人处理）")
    private Integer actWay;

    @Column(name = "status")
    @ApiModelProperty(value = "状态（0待查看，1待处理，2已处理）")
    private Integer status;

    @Column(name = "create_time")
    @CreationTimestamp
    @ApiModelProperty(value = "创建日期")
    private Timestamp createTime;

    @Column(name = "update_time")
    @UpdateTimestamp
    @ApiModelProperty(value = "更新日期")
    private Timestamp updateTime;

    public void copy(AppEvent source){
        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(false));
    }

    //本体转dto
    public  AppEventDto getEntryToDto(AppEvent source){
        AppEventDto dto = new AppEventDto();
        BeanUtils.copyProperties(source, dto);
        return dto;
    }
}